From: Paul Donald Date: Tue, 8 Jul 2025 12:27:05 +0000 (+0200) Subject: luci-base: tweak dispatcher logging to post under correct facility X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22http:/www.crowdsec.net/%22/%22https:/collectd.org/%22http:/www.crowdsec.net/%22?a=commitdiff_plain;h=81692c6c382f079eda4974d72c091b992d270d13;p=project%2Fluci.git luci-base: tweak dispatcher logging to post under correct facility Previously we might see: ... daemon.err uhttpd[5153]: [info] luci: accepted login on / for root from x.x.x.x Now: ... authpriv.info dispatcher.uc: luci: accepted login on / for root from x.x.x.x Signed-off-by: Paul Donald --- diff --git a/modules/luci-base/Makefile b/modules/luci-base/Makefile index d9832e3393..7f5d1809fb 100644 --- a/modules/luci-base/Makefile +++ b/modules/luci-base/Makefile @@ -21,6 +21,7 @@ LUCI_DEPENDS:=\ +cgi-io \ +ucode \ +ucode-mod-fs \ + +ucode-mod-log \ +ucode-mod-uci \ +ucode-mod-ubus \ +ucode-mod-math \ diff --git a/modules/luci-base/ucode/dispatcher.uc b/modules/luci-base/ucode/dispatcher.uc index 2cb8cc2f6c..09e53b885a 100644 --- a/modules/luci-base/ucode/dispatcher.uc +++ b/modules/luci-base/ucode/dispatcher.uc @@ -6,6 +6,7 @@ import { striptags, entityencode } from 'html'; import { connect } from 'ubus'; import { cursor } from 'uci'; import { rand } from 'math'; +import { openlog, syslog, closelog, LOG_INFO, LOG_WARNING, LOG_AUTHPRIV } from 'log'; import { hash, load_catalog, change_catalog, translate, ntranslate, getuid } from 'luci.core'; import { revision as luciversion, branch as luciname } from 'luci.version'; @@ -485,10 +486,6 @@ function randomid(num_bytes) { return join('', bytes); } -function syslog(prio, msg) { - warn(sprintf("[%s] %s\n", prio, msg)); -} - function session_setup(user, pass, path) { let timeout = uci.get('luci', 'sauth', 'sessiontime'); let login = ubus.call("session", "login", { @@ -497,19 +494,22 @@ function session_setup(user, pass, path) { timeout: timeout ? +timeout : null }); + openlog('dispatcher.uc'); if (type(login?.ubus_rpc_session) == 'string') { ubus.call("session", "set", { ubus_rpc_session: login.ubus_rpc_session, values: { token: randomid(16) } }); - syslog("info", sprintf("luci: accepted login on /%s for %s from %s", + syslog(LOG_INFO|LOG_AUTHPRIV, sprintf("luci: accepted login on /%s for %s from %s", join('/', path), user || "?", http.getenv("REMOTE_ADDR") || "?")); return session_retrieve(login.ubus_rpc_session); } - syslog("info", sprintf("luci: failed login on /%s for %s from %s", + syslog(LOG_WARNING|LOG_AUTHPRIV, sprintf("luci: failed login on /%s for %s from %s", join('/', path), user || "?", http.getenv("REMOTE_ADDR") || "?")); + + closelog(); } function check_authentication(method) {